package com.suneast.suneaststore.modules.common;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.suneast.suneaststore.util.log.LatteLogger;

public class CommonUtil {

    public static JSONObject parseDataFromRootJSON(String response) {
        JSONObject rootObj = JSON.parseObject(response);
        if (rootObj != null) {
            if (rootObj.getIntValue("code") == 1) {
                return rootObj.getJSONObject("data");
            } else {
                LatteLogger.e("error", "request data success but code = "
                        + rootObj.getIntValue("code")
                        + " msg = " + rootObj.getString("msg"));
            }
        }
        return null;
    }

//    public static <T> List<T> parseBeanList(Class<T> t, String jsonList) {
//        return JSON.parseArray(jsonList,t);
//    }
}
